package com.scau.service.impl;

import com.scau.dao.MenuMapper;
import com.scau.pojo.Menu;
import com.scau.pojo.MenuExample;
import com.scau.service.IMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MenuServiceImpl implements IMenuService {

    @Autowired
    MenuMapper menuMapper;

    @Override
    public void addMenu(Menu menu) {
        menuMapper.insert(menu);
    }

    @Override
    public void updateMenu(Menu menu) {

        menuMapper.updateByPrimaryKeySelective(menu);

    }

    @Override
    public Menu selectMenu(int menuId) {
        Menu menu = menuMapper.selectByPrimaryKey(menuId);
        return menu;
    }

    @Override
    public List<Menu> showMenus() {
        MenuExample menuExample = new MenuExample();
        menuExample.createCriteria().andIdIsNotNull();

        List<Menu> menuList = menuMapper.selectByExample(menuExample);
        return menuList;
    }

    @Override
    public void deleteMenu(int menuId) {
        menuMapper.deleteByPrimaryKey(menuId);
    }
}
